using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Services.Identity.Domain.Entities;

namespace Services.Identity.Infrastructure.Configs;
public class UserPermissionConfig : IEntityTypeConfiguration<UserPermission>
{
    public void Configure(EntityTypeBuilder<UserPermission> builder)
    {
        builder.ToTable("T_UserPermission");
        builder.HasKey(x => x.Id);
        builder.Property(x => x.Id).UseHiLo();
        builder.OwnsOne(x=>x.PermissionNameAndRouter);
        builder.HasMany(e=>e.Roles).WithMany(e=>e.UserPermissions).UsingEntity("T_PermissionAndRole");
    }
}